package cn.itsource.org.service.impl;

import cn.itsource.basic.service.impl.BasicServiceImpl;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.domain.Shop;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.mapper.ShopMapper;
import cn.itsource.org.service.IEmployeeService;
import cn.itsource.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ShopServiceImpl extends BasicServiceImpl<Shop> implements IShopService{

    @Autowired
    private EmployeeMapper employeeMapper;

    @Autowired
    private ShopMapper shopMapper;


    @Override
    @Transactional
    public void settlement(Shop shop) {
       //1.先保存员工对象  返回主键
        employeeMapper.save(shop.getAdmin());
        //2.保存shop对象
        super.add(shop);

       /* Employee admin = shop.getAdmin();
        employeeMapper.save(admin);

        shop.setAdmin(admin);

        shopMapper.save(shop);*/



    }

    @Override
    public List<Shop> queryAllByState() {
        return shopMapper.queryAllByState();
    }
}
